package org.soar.views.uicomponent;

import java.util.Map;

import android.content.Context;
import android.view.ViewGroup;

import org.soar.SoarApplication;

public class UIComponentFactory {

	public static SoarUIComponent buildUIComponentFromCache(SoarUIComponent uicomponent,Map data) {
		SoarUIComponent comp = null;
		uicomponent.initFromCache(uicomponent.context, uicomponent.getParent(), data, uicomponent.uiConfig);
		return comp;
	}
	public static <T extends SoarUIComponent> T buildUIComponent(Class<T> clazz, Context context) {
		T comp = null;
		comp = buildUIComponent(clazz,context, null, null, null);
		return comp;
	}
	public static <T extends SoarUIComponent> T buildUIComponent(Class<T> clazz, Context context,Map data) {
		T comp = null;
		comp = buildUIComponent(clazz,context, null, data, null);
		return comp;
	}
	public static <T extends SoarUIComponent> T buildUIComponent(Class<T> clazz, Context context,Map data,UIComponentConfig config) {
		T comp = null;
		comp = buildUIComponent(clazz,context, null, data, config);
		return comp;
	}
	
	public static <T extends SoarUIComponent> T buildUIComponent(Class<T> clazz, Context context,ViewGroup parent,Map data,UIComponentConfig config) {
		T comp = null;
		comp = ((SoarApplication)context.getApplicationContext()).getInjector().getInstance(clazz);
		comp.init(context, parent, data, config);
		return comp;
	}
	
}